import request from '@/utils/request'

export function getData(requestBody) {
  // console.log(requestBody)
  return request({
    url: '/template/list',
    method: 'post',
    data: requestBody,
  })
}

export function getAnswerType() {
  return request({
    url: '/template/answerType/list',
    method: 'get',
  })
}

export function getTemplateType() {
  return request({
    url: '/template/type/list',
    method: 'get',
  })
}

export function addTemplate(form) {
  // console.log(requestBody)
  return request({
    url: '/template/add',
    method: 'post',
    data: form,
  })
}

export function updateTemplate(form) {
  // console.log(requestBody)
  return request({
    url: '/template/update',
    method: 'post',
    data: form,
  })
}

export function updateTemplateInFlowDiagram(nodeForm) {
  return request({
    url: '/template/flowDiagram/update',
    method: 'post',
    data: nodeForm,
  })
}

export function deleteTemplateNode(id) {
  return request({
    url: '/template/flowDiagram/deleteNode',
    method: 'post',
    data: { id },
  })
}

export function addTemplateEdge(edgeForm) {
  return request({
    url: '/template/flowDiagram/addEdge',
    method: 'post',
    data: edgeForm,
  })
}

export function deleteTemplateEdge(edgeDeleteForm) {
  return request({
    url: '/template/flowDiagram/deleteEdge',
    method: 'post',
    data: edgeDeleteForm,
  })
}

export function updateStatus(id) {
  return request({
    url: '/template/update/status',
    method: 'post',
    data: { id },
  })
}

export function getTemplateById(id) {
  return request({
    url: '/template/getById?id=' + id,
    method: 'get',
  })
}

export function updateStatusTRUE(ids) {
  return request({
    url: '/template/update/status/true',
    method: 'post',
    data: ids,
  })
}

export function updateStatusFALSE(ids) {
  return request({
    url: '/template/update/status/false',
    method: 'post',
    data: ids,
  })
}

export function deleteTemplateById(id) {
  return request({
    url: '/template/delete',
    method: 'post',
    data: { id },
  })
}

export function deleteTemplateAll(id) {
  // console.log(requestBody)
  return request({
    url: '/template/deleteAll',
    method: 'post',
    data: { id },
  })
}
